
import { getTrainingProgram, getTrainingCourse } from "../../../services/trainingProgram"
export default {

  namespace: 'trainingProgramModule',
  state: {
    list: "",
    course:[]
  },

  effects: {
    *getTrainingProgramInfo({ payload }, { call, put }) {
      let { objData } = yield getTrainingProgram(payload)
      let data = yield getTrainingCourse({schemeId:objData.id})
      yield put({
        type: "setList",
        payload: objData
      })
      yield put({
        type: "setCourse",
        payload: data.rows
      })
    },

    *fetch({ payload }, { call, put }) {  // eslint-disable-line
      yield put({ type: 'save' });
      
    },
  },

  reducers: {
    setList(state, { payload }) {
      state.list = payload
      return { ...state, ...payload };
    },
    setCourse(state, { payload }) {
      state.course = payload
      return { ...state, ...payload };
    },
  },

};
